window.onload = function() {
	
	//点击叉号图片实现关闭效果
	var btn=document.querySelector('.close-btn');
	var erweima=document.querySelector('.erweima');
	btn.onclick=function(){
		erweima.style.display='none';
	}
	
	// 轮播图效果
	var lbimg = document.querySelector(".lbimg");
	var lbimgs = lbimg.querySelectorAll("li");
	var btn = document.querySelector(".btn");
	var btns = btn.querySelectorAll("li");

	for (var i = 0; i < btns.length; i++) {

		btns[i].index = i;
		btns[i].onclick = function() {
			clearInterval(timer);
			for (var j = 0; j < lbimgs.length; j++) {
				lbimgs[j].className = "";
			}
			// 按钮颜色跟着变化
			for (var k = 0; k < btns.length; k++) {
				btns[k].className = "";
			}
			// 轮播同步，点击后图片的位置从点击的地方开始轮播
			index = this.index;
			btns[this.index].className = "active";
			lbimgs[this.index].className = "on";
			timer = setInterval(autoPlay, 1000);
		}
	}
	var index = 0;
	// 自动轮播
	index++;
	var timer = setInterval(autoPlay, 1000);

	function autoPlay() {
		for (var i = 0; i < lbimgs.length; i++) {
			lbimgs[i].className = "";
		}
		for (var j = 0; j < btns.length; j++) {
			btns[j].className = "";
		}
		if (index == lbimgs.length - 1) {
			index = 0;
		} else {
			index++;
		}
		btns[index].className = "active";
		lbimgs[index].className = "on";
	}

	// 鼠标移动时清除定时器
	lbimg.onmouseover = function() {
		clearInterval(timer);
	}
	lbimg.onmouseout = function() {
		timer = setInterval(autoPlay, 2000);
	}

	//侧拉二级菜单效果
	var nav=document.querySelector('.nav');
	var lis=nav.children;
	for(var i=0;i<lis.length;i++){
		lis[i].onmouseover=function(){
			this.children[1].style.display='block';
		}
		lis[i].onmouseout=function(){
			this.children[1].style.display='none';
		}
	}
	
	// 鼠标经过图片放大效果
	var ulyouzhihuiyuan = document.getElementById('youzhihuiyuanID');
	var img = ulyouzhihuiyuan.getElementsByTagName('img');	
	for(var i=0;i<img.length;i++)
	{
		img[i].onmouseover = function() {
			this.style.cssText = "animation: bigger 1s;width:110%; height:110%;";
		}
		img[i].onmouseout = function() {
			this.style.cssText = "animation: smaller 1s";
		}
	}

	
}





